package day07;


import java.util.Scanner;

public class CalAirPrice {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入机票原价");
        double price=sc.nextDouble();
        System.out.println("输入月份");
        int month= sc.nextInt();
        while (month<1||month>12){
            System.out.println("请输入正确月份：1-12");
            month=sc.nextInt();
        }
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type=sc.nextInt();
        while (type<1||type>3){
            System.out.println("没有配备该舱");
            type= sc.nextInt();
        }
        double finalPrice=calAirPrice(price,month,type);
        System.out.println("机票最终价格为:"+finalPrice);

    }
    public static double calAirPrice(double price,int month,int type){
        double finalPrice=0.0;
        switch (month){
            case 1:
            case 2:
            case 3:
            case 4:
            case 11:
            case 12:
                if (type==1){
                    finalPrice=price*0.7;
                }else if (type==2){
                    finalPrice=price*0.65;
                }else{
                    finalPrice=price*0.6;
                }
                break;
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
                if (type==1){
                    finalPrice=price*0.9;
                }else if (type==2){
                    finalPrice=price*0.85;
                }else{
                    finalPrice=price*0.8;
                }
                break;

        }

        return finalPrice;
    }
}
